Repository navigation
Document model pricing, the agent's per-session spend caps, and final cancels - #727
DavidCockerill wants to merge 25 commits into
Conversation
Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a cap counts agent.maxTokens is the per-reply output limit (#712). Also: a failed call is never counted, an unmeasurable cap on a final answer ends completed, invalid caps fail the agent's start, and auto-mode costUsd covers the final round. Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…efused approval does not run later Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the 5.4 release notes HarperFast/harper#3040 is milestoned v5.4, which is main, so it ships in 5.4.0 rather than a 5.3 patch. Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t stays in the total Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…xact about costUsd and capped final answers Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sts until restart, and note streaming is unpriced Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ishes Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… captured at run start Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a mid-turn cancel answers the rest of the turn Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🚀 Preview DeploymentYour preview deployment is ready! 🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-727 This preview will update automatically when you push new commits. |
There was a problem hiding this comment.
Code Review
This pull request updates the documentation for version 5.4.0, introducing model pricing, per-call cost tracking, and spend caps (maxSessionTokens and maxCostUsd) for the built-in agent. It also details updates to the operations API regarding session status, usage reporting, and cancellation behavior. The review feedback suggests using a VersionBadge to highlight the new costUsd field in the API documentation, and recommends splitting combined sentences in the tool-calling and operations guides to make fallback behaviors more distinct and readable.
… spend caps The agent's maxTokens, configScope and maxToolResultBytes docs landed in the same sections; the set_agent_config key list, the captured-at-start list and the 5.4 Built-in Agent notes now carry all of them. A reply the agent rejects as cut off or empty stays out of the transcript but its usage is kept on the session (rejectedCalls) and counted. Two cancel and auto-loop sentences are split for scanning. Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…resend a prompt recorded but not run Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…is answered Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs HarperFast/harper#3040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nly an approved one Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…that caps bound one session Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g on an unmeasurable cap, and a bare maxTurns failing the start Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d what a bare cap key does Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🚀 Preview DeploymentYour preview deployment is ready! 🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-727 This preview will update automatically when you push new commits. |
⊙ Problem
agent: carry per-call token usage onto the session and enforce a budget (HarperFast/harper#3040) enforces the agent's
maxCostUsd, addsagent.maxSessionTokens, session usage and model pricing, and makes a cancel final. The reference still callsmaxCostUsd"not enforced", with a5.00default.Refs HarperFast/harper#3040. Companion to Cap the agent's spend per session by tokens or priced cost, record its model usage, and make a cancel final (HarperFast/harper#3177).
🤔 Should these docs merge with the core PR?
Yes. They cover new config keys, a new response field, and changed
status, 409 and cancel behavior that clients key on. Dated v5.4.0 to match the core milestone.💡 Solution
pricingfield,costUsdonGenerateResult, unpriced streaming, andmaxCostUsdfortoolMode: 'auto'.maxSessionTokensandmaxCostUsdoptions and a new Agent spend caps subsection: what a cap counts, when it is checked, and how a stop ends a session.usageon session reads, cap stops instatus,agent_prompt's new 409s and their codes, at-most-once approved actions, and what a cancel does to approvals.🔧 Changes
runInFlighton session reads, the auto loop'smaxToolTokensandmaxCostUsdstopping it when they cannot be measured, and what a bare cap key does.set_agent_config's key list and settings captured at run start gain the caps;list_agent_sessionsreports the same totals.maxTurnsis validated, a bare key failing the start.api.mdandtool-calling.mdhunks also re-align their tables, which Prettier does when a wider row is added.✅ Verification
npm run format:checkpasses.integrationTests/server/agent-budget.test.tsand its agent unit suites.🤖 Generated by Claude Code (Anthropic Claude Opus 5.5); posted via @DavidCockerill.
Related PRs: #712 overlaps (merged here;
agent.maxTokensin the same agent options,set_agent_configtext and 5.4 notes), #717 overlaps (merged here;agent.configScopein the same agent options andset_agent_configtext), #720 overlaps (merged here;agent.maxToolResultBytesin the same agent options andset_agent_configtext), 2 others independentComplexity: medium
Deferred findings
6c2d1cefc7c6cd2cminor correctness —reference/configuration/options.md— Billed failed calls excluded from session caps — filed agent spend caps: count billed failed calls where possible, and recover a session one unmeasured call stranded harper#32951ca509ed904c3cacminor reliability —reference/configuration/options.md— One unmeasured call (pre-5.4 or a provider hiccup) strands a session under a cap — filed agent spend caps: count billed failed calls where possible, and recover a session one unmeasured call stranded harper#3295Review-Coverage: authored=claude; ran=gemini,codex; adjudicated=domain; blocked=cursor-composer(not-installed); declined=cursor-grok,cursor-kimi,cursor-muse,muse; rounds=14; full=3 @ 569af46
Review-Attention: skim ~2m (decisions: bare-cap-key-unsets, run-in-flight-node-local, structured-409-codes, auto-loop-unmeasured-fails-closed, session-scoped-budget, failed-calls-uncounted) @ 569af46